<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html class="win-frame">
<head>
<title>用户管理-编辑用户</title>
<%@include file="/common/head.jsp" %>
<link href="<%=request.getContextPath()%>/static/plugin/zTree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet">
<link href="<%=request.getContextPath()%>/static/styles/css/org.css" rel="stylesheet">
<script src="<%=request.getContextPath()%>/static/plugin/zTree/js/jquery.ztree.all-3.5.min.js"></script>
<script src="<%=request.getContextPath()%>/static/js/org.js"></script>
<style type="text/css">
 .tree-title {
    border-bottom: 2px solid #fb9337;
    color: #666;
    font-size: 13px;
    font-weight: 600;
    margin: 0 15px 15px 0;
    padding: 0 40px 5px 5px;
    background-color: #ffffff;
 }
</style>
</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>用户管理</span>
            <span class="split"></span>
            <span>编辑用户</span>
        </div>
        <a id="goBack" class="btn-return distance-left" href="javascript:;"><i class="icon icon-arrow-left"></i>返回上级</a>
    </div>
    <div class="page-title-border"></div>
</div>

<form id="userForm" method="post">
<div id="left" style="width:80%;float:left">
    <div class="form-wrapper">
	  <div class="h4 distance-double">
        <span class="h4-title"><i class="icon icon-setting"></i>基本信息</span>
        <span class="h4-border"></span>
      </div>
     
      <div class="form-cont">
	       <p class="form-cont-title"><span class="field-required">*</span>登录名</p>
	       <input type="text" id="username" name="username" class="summer-input" readonly="readonly"/> 
		   <input type="hidden" id="id" name="id"/> 
	  </div>
	  
	  <div class="form-cont">
        <p class="form-cont-title"><span class="field-required">*</span>姓名</p>
        <input type="text" id="realname" name="realname" class="summer-input summer-validatebox" data-validatebox="validType:['required','maxLength[40]']"/>
      </div>
      
      <div class="form-cont">
        <p class="form-cont-title"><span class="field-required">*</span>所属机构</p>
        <input type="text" id="orgName" name="org" readonly="readonly" class="summer-input summer-validatebox distance-right" data-validatebox="tipPosition:'bottom',validType:['required']"/>
     </div>
     
     <div class="form-cont">
        <p class="form-cont-title"><span class="field-required">*</span>人员类型</p>
        <input type="text" id="type" name="type" class="summer-input summer-validatebox" data-validatebox="validType:['required']"/>
     </div>
	     
     <div class="form-cont">
        <p class="form-cont-title"><span class="field-required">*</span>用户状态</p>
        <input type="text" id="isUsable" name="isUsable" class="summer-input summer-validatebox" data-validatebox="validType:['required']"/>
     </div>
     
     <div class="form-wrapper">
	 <div class="h4 distance-double">
        <span class="h4-title"><i class="icon icon-setting"></i>详细信息</span>
        <span class="h4-border"></span>
     </div> 
     
    <div class="form-cont">
        <p class="form-cont-title">性别</p>
        <input type="text" id="gender" name="gender" class="summer-input"/>
     </div>
     
     <div class="form-cont">
        <p class="form-cont-title">电话</p>
       <input type="text" id="tel" name="tel" class="summer-input summer-validatebox" data-validatebox="validType:['phone']"/>
     </div>
     
     <div class="form-cont">
        <p class="form-cont-title">手机</p>
        <input type="text" id="mobile" name="mobile" class="summer-input summer-validatebox" data-validatebox="validType:['mobile']"/>
     </div>
     
     <div class="form-cont">
        <p class="form-cont-title">邮箱</p>
        <input type="text" id="email" name="email" class="summer-input summer-validatebox" data-validatebox="validType:['email']"/>
     </div>
     
     <div class="form-cont">
        <p class="form-cont-title">职位</p>
         <input type="text" id="position" name="position" class="summer-input summer-validatebox" data-validatebox="validType:['maxLength[40]']"/>
     </div>
     
     <div class="form-cont">
        <p class="form-cont-title">排序号</p>
        <input type="text" id="orderNo" name="orderNo" class="summer-input summer-validatebox" data-validatebox="validType:['betweenInteger[1,100000]']"/>
     </div>
     
     <div class="form-btn-wrapper" id="funcbar">
        <a class="btn btn-normal" id="backBtn">关闭</a>
    </div>
  </div>
  </div>   
</div>
</form>
<script>
    var userData = ${sysUser},
        orgCode = userData.org, //用户管理页面选中的组织机构树
        permission = CommonUtil.getPermission('user');
    
    $(function () {
    	//初始化funcbar
	   	$('#funcbar').prepend($.funcbar({
	            type: 'button',
	            data: permission,
	            permit: ['user:edit']
	    }));
    	
	    //组织机构树
	   	 $('#orgName').org({
			  'selectedMulti': false,
		      'event': 'keyup',
		      'url': USER_CONST_URL.ORG_TREE,
		      'idKey': 'code',
		      'pIdKey': 'pCode',
		      'rootId': orgCode,
		      'height': 450,
		      'width': 600
	   	 });
    	//初始化人员类型
    	initCombobox('type', COMMON_URL.getCode + '?type=T_DM_USER_TYPE');
    	//初始化用户状态
    	initCombobox('isUsable', COMMON_URL.getCode + '?type=T_DM_USER_ISUSABLE');
    	//初始化性别
    	initCombobox('gender', COMMON_URL.getCode + '?type=T_DM_USER_GENDER');
    	
        $('#userForm').form({
        	onLoadSuccess:function(data){
        		$('#orgName').org('setValues',data.org);
        	}
        }).form('loadDataEdit', {
            data: userData
        }); 
    	
    	
    	//保存按钮
    	$('#funcbar').on('click', 'a[data-permit="user:edit"]', submit);
    	
    	//返回按钮
    	$('#backBtn, #goBack').on('click',backMain);
    });
    
    
    //初始化combobox
    function initCombobox(id, url, defaultValue, async, menuHeight) {
        $('#' + id).combobox({
            valueField: 'code',
            textField: 'name',
            async: async? async: false,
            url: url,
            menuHeight: menuHeight? menuHeight: 'auto',
            defaultValue: defaultValue ? defaultValue : '' 
        });
    }
    
    //表单提交
    function submit() {
         $("#userForm").form({
        	 buttons : ['#saveBtn'],
             ajax: {
                 url: USER_CONST_URL.EDIT
             },
             onSubmitSuccess: function (data) {
            	 $.stip({
   	                type:'ok',//显示类型 有info、 ok、 danger
   	                text: '保存成功！',
   	                onBeforeHide: function () {
   	                	backMain();
   	                }
            	 });
              }
         }).form("submit");
    }
    
    
    //返回主页面
    function backMain() {
    	window.location.href = USER_CONST_URL.INIT_MAIN;
    }
    
    //请求url
    var USER_CONST_URL = {
    	INIT_MAIN: basePath + '/sys/user/init',
       	EDIT: basePath + "/sys/user/edit",
       	ORG_TREE: basePath + '/sys/inner/getOrgTree'
    };
    
</script>
</body>
</html>